import { _decorator, Component, instantiate, Node, Prefab, sys } from 'cc';
import { PRIVACY_POLLICY_SWITCH, PRIVACY_POLLICY_VERSION } from './Define';
const { ccclass, property } = _decorator;

@ccclass('Base')
export class Base extends Component {

    @property(Prefab)
    public safeLayerPrefab:Prefab = null 
   
    onLoad(){ 
         if(sys.localStorage.getItem("PRIVACY_POLLICY_VERSION") != PRIVACY_POLLICY_VERSION) {
           sys.localStorage.setItem("PRIVACY_POLLICY_VERSION",PRIVACY_POLLICY_VERSION)
           sys.localStorage.removeItem("PRIVACY_POLLICY_SWITCH_STRING")
         }
         if (sys.localStorage.getItem("PRIVACY_POLLICY_SWITCH_STRING") != 1) {
                const safeLayerNode = instantiate(this.safeLayerPrefab)
				        safeLayerNode.parent = this.node.parent
				        safeLayerNode.setPosition(this.node.position)
                sys.localStorage.setItem("PRIVACY_POLLICY_SWITCH_STRING",PRIVACY_POLLICY_SWITCH.ON)     
         }
	}

}

